﻿var StatusNG = 0;
var StatusUP = 1;
var StatusOK = 2;

var IdxBrowser = 0;
var IdxJs = 1;
var IdxCookie = 2;
var IdxPopup = 3;
var IdxFlash = 4;
var IdxJre = 5;

function SetCookie(name, value, expires) {

    document.cookie = name + "=" + encodeURIComponent(value) + ";expires=" + expires.toGMTString() + ";path=/;";
}
function showEachClientCheckResult() {
    window.setTimeout("browser_check.innerHTML = Msg[IdxBrowser][getBrowserStatus()];", 1000);

    //window.setTimeout("testnow.style.display = \"none\";", 1000);
    //popup_check.innerHTML   = Msg[IdxPopup][getPopupStatus("./js/close_window.htm")];
}
function GetCookie(name) {
    var arg = name + "=";
    var arg_len = arg.length;
    var cookie_length = document.cookie.length;
    var i = 0;
    while (i < cookie_length) {
        var j = i + arg_len;
        if (document.cookie.substring(i, j) == arg) {
            return getValue(j);
        }
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}
function getBrowserStatus() {
    var status = StatusNG;
    if (!checkBrowserName(" MSIE ") || !checkBrowserName("MSIE ") || !checkBrowserName("MSIE")) {
        status = StatusNG;
    } else {
        status = StatusOK;
    }
    window.setTimeout("js_check.innerHTML      = Msg[IdxJs][StatusOK];window.setTimeout(\"cookie_check.innerHTML = Msg[IdxCookie][getCookieStatus()];\", 1000);", 1000);

    return status;
}
function getCookieStatus() {
    var status = StatusNG;
    var cookieStr = "wb_check=kcehc_bw";
    document.cookie = cookieStr;
    if (document.cookie.indexOf(cookieStr) > -1) {
        status = StatusOK;
        var date = new Date();
        date.setTime(date.getTime() - 1000);
        document.cookie = cookieStr + "; expires=" + date.toGMTString();
    }
    window.setTimeout("testnow.innerText=\"检测完成\";", 1000);
    return status;
} 
function checkBrowserName(name) {
    var verStr = navigator.appVersion;
    var verNo = 0;
    var result = false;
    if (verStr.indexOf(name) != -1) {
        tempStr = verStr.split(name);
        verNo = parseFloat(tempStr[1]);
        if (verNo >= 5) {
            result = true;
        }
    }
    return result;
}